const Koa = require('koa');
const router = require('koa-router')();
const views = require('koa-views');
const bodyParser = require('koa-bodyparser');
const static = require('koa-static');
const {resolve}= require('path');
/* 配置静态资源 */
const app = new Koa();
app.use(static(resolve(__dirname,'static')));
app.use(views('views',{
    extension:'ejs'
}))
app.use(bodyParser())
router.get('/',async ctx=>{
    await ctx.render('index')
})
/* 接收post提交的数据*/
router.post('/add',async ctx=>{
    console.log(ctx.request.body)
})
app.use(router.routes()).use(router.allowedMethods())
app.listen(8080)